package com.wt.dao;

import com.wt.pojo.OrderInforItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

public interface OrderInforItemMapper {
    @Delete({
        "delete from brand_admin_order_infor_item",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into brand_admin_order_infor_item (id, order_infor_id, ",
        "vendor_id, member_id, ",
        "goods_id, control, goods_name, ",
        "logo, price, amount, ",
        "total_price, delivery_id, ",
        "delivery_name, express, ",
        "delivery_price, status, ",
        "time, deal_time, send_time, ",
        "complete_time, appraise, ",
        "message, pay_type, trade_no, ",
        "presell, order_guid, ",
        "order_type)",
        "values (#{id,jdbcType=INTEGER}, #{orderInforId,jdbcType=INTEGER}, ",
        "#{vendorId,jdbcType=INTEGER}, #{memberId,jdbcType=INTEGER}, ",
        "#{goodsId,jdbcType=INTEGER}, #{control,jdbcType=CHAR}, #{goodsName,jdbcType=VARCHAR}, ",
        "#{logo,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{amount,jdbcType=INTEGER}, ",
        "#{totalPrice,jdbcType=DECIMAL}, #{deliveryId,jdbcType=TINYINT}, ",
        "#{deliveryName,jdbcType=CHAR}, #{express,jdbcType=CHAR}, ",
        "#{deliveryPrice,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, ",
        "#{time,jdbcType=CHAR}, #{dealTime,jdbcType=INTEGER}, #{sendTime,jdbcType=INTEGER}, ",
        "#{completeTime,jdbcType=INTEGER}, #{appraise,jdbcType=CHAR}, ",
        "#{message,jdbcType=VARCHAR}, #{payType,jdbcType=CHAR}, #{tradeNo,jdbcType=VARCHAR}, ",
        "#{presell,jdbcType=TINYINT}, #{orderGuid,jdbcType=CHAR}, ",
        "#{orderType,jdbcType=TINYINT})"
    })
    int insert(OrderInforItem record);

    int insertSelective(OrderInforItem record);

    @Select({
        "select",
        "id, order_infor_id, vendor_id, member_id, goods_id, control, goods_name, logo, ",
        "price, amount, total_price, delivery_id, delivery_name, express, delivery_price, ",
        "status, time, deal_time, send_time, complete_time, appraise, message, pay_type, ",
        "trade_no, presell, order_guid, order_type",
        "from brand_admin_order_infor_item",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    OrderInforItem selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(OrderInforItem record);

    @Update({
        "update brand_admin_order_infor_item",
        "set order_infor_id = #{orderInforId,jdbcType=INTEGER},",
          "vendor_id = #{vendorId,jdbcType=INTEGER},",
          "member_id = #{memberId,jdbcType=INTEGER},",
          "goods_id = #{goodsId,jdbcType=INTEGER},",
          "control = #{control,jdbcType=CHAR},",
          "goods_name = #{goodsName,jdbcType=VARCHAR},",
          "logo = #{logo,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=DECIMAL},",
          "amount = #{amount,jdbcType=INTEGER},",
          "total_price = #{totalPrice,jdbcType=DECIMAL},",
          "delivery_id = #{deliveryId,jdbcType=TINYINT},",
          "delivery_name = #{deliveryName,jdbcType=CHAR},",
          "express = #{express,jdbcType=CHAR},",
          "delivery_price = #{deliveryPrice,jdbcType=DECIMAL},",
          "status = #{status,jdbcType=INTEGER},",
          "time = #{time,jdbcType=CHAR},",
          "deal_time = #{dealTime,jdbcType=INTEGER},",
          "send_time = #{sendTime,jdbcType=INTEGER},",
          "complete_time = #{completeTime,jdbcType=INTEGER},",
          "appraise = #{appraise,jdbcType=CHAR},",
          "message = #{message,jdbcType=VARCHAR},",
          "pay_type = #{payType,jdbcType=CHAR},",
          "trade_no = #{tradeNo,jdbcType=VARCHAR},",
          "presell = #{presell,jdbcType=TINYINT},",
          "order_guid = #{orderGuid,jdbcType=CHAR},",
          "order_type = #{orderType,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(OrderInforItem record);
    BigDecimal selectTradeCountByDistributorId(Integer id);
    BigDecimal selectTradeCountByAll();
    BigDecimal selectAccountTotal(Integer id);
    BigDecimal selectAccountAll();
    BigDecimal selectTradeCommission();
    Long selectCountOrders();

}